<?php

$gp = $_POST["gp"];
$medinum = $_POST["medinum"];
$mediref = $_POST["mediref"];
$userID= $_POST["userID"];
if($gp != "" && $medinum != "" && $mediref != "" && $userID != "")
	connect_database();

function connect_database(){
		$mysqli = new mysqli('localhost', 'root', '', 'gluphien');
		//echo $DBConnect;
		if ($mysqli->connect_errno)
			echo "<p>Connection Failed.</p>";
		$SQLstring = "UPDATE `userdetails` SET gp='" . $GLOBALS["gp"] . "' WHERE userID='" . $GLOBALS["userID"] . "'";
		if (mysqli_query($mysqli, $SQLstring) === TRUE) {
			$SQLstring = "UPDATE `userdetails` SET medicarenum='" . $GLOBALS["medinum"] . "' WHERE userID='" . $GLOBALS["userID"] . "'";
			if (mysqli_query($mysqli, $SQLstring) === TRUE) {
				$SQLstring = "UPDATE `userdetails` SET medicareref='" . $GLOBALS["mediref"] . "' WHERE userID='" . $GLOBALS["userID"] . "'";
				if (mysqli_query($mysqli, $SQLstring) === TRUE)
					echo "<p>Successfully updated medical information</p>";
				else
					echo $mysqli->error();
			}
			else
				echo $mysqli->error();
		}
		else
			echo $mysqli->error();
		
		
		$mysqli->close();
	}
?>